package logic

import (
	"context"
	"week1/textrpc/textrpc"

	"week1/client/internal/svc"
	"week1/client/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CreateJvBaoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCreateJvBaoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateJvBaoLogic {
	return &CreateJvBaoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CreateJvBaoLogic) CreateJvBao(req *types.CreateJvBaoReq) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	_, err = l.svcCtx.TextRpc.CreateJvBao(l.ctx, &textrpc.CreateJvBaoReq{
		TextId:  req.TextId,
		Userid:  req.Userid,
		Comment: req.Comment,
	})
	if err != nil {
		return &types.Response{
			Code:    400,
			Message: err.Error(),
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "举报成功，请等待审核",
		Data:    nil,
	}, nil
}
